package com.problemproject.dome.gridView;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.problemproject.dome.R;

import java.lang.ref.PhantomReference;
import java.util.List;

/**
 * 创建时间 : 2022/4/1
 * 描述：
 */

public class GridViewAdapter extends BaseAdapter {
    private Context mContext;
    private List<String> mList;

    public GridViewAdapter(Context mContext, List<String> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size() !=0?mList.size():0;
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder mViewHolder;
        if (convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_auto_gridview,parent,false);
            mViewHolder = new ViewHolder();
            mViewHolder.autoGridView = (TextView) convertView.findViewById(R.id.autoGridView);
            convertView.setTag(mViewHolder);
        }else {
            mViewHolder = (ViewHolder) convertView.getTag();
        }

        mViewHolder.autoGridView.setText(mList.get(position));
        return convertView;
    }

    class ViewHolder{
        private TextView autoGridView;


    }
}
